<?php

namespace App\Console\Commands;

use App\Models\Record;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class inspire extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'inspire';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '定期清理record表中的数据，软删除过期的数据';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        Log::info("inspire命令执行了");
//        这里将判断表record中的数据，expired_at大于当前时间，删除
        $count = Record::where('expired_at', '>', Carbon::now())->delete();
        $this->info('inspire命令执行了,删除了'.$count.'条数据');
    }
}
